<!DOCTYPE html>
<html lang="zh-CN" ng-app='he'>
	<head>
		<meta charset='utf-8' />
	
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>请假详情</title>
		<script type="text/javascript">
			is_local='{{local}}';
			function loadcss(cssfile) {
		        document.write('\<link rel="stylesheet" href="' + cssfile +'" type="text/css"/\>');
		    }
			function loadjs(script_filename) {
		        document.write('\<script language="javascript" type="text/javascript" src="' + script_filename + '"\>\</script\>');
		    }
		    if(!is_local){
			    static_url='/static';
		    }else{
			    static_url='../../../../static';
		    }
		    // 加载所有微信页面需要的js和css
		    loadjs(static_url+'/js/weixin_page.js')
		</script>
		
		<script type="text/javascript">
			var app = angular.module('he',['ngSanitize']);
			app.config(function($interpolateProvider) {
				  $interpolateProvider.startSymbol('[[');
				  $interpolateProvider.endSymbol(']]');
				});
			app.run(function($rootScope){
				$rootScope.static=static_url;
			})
			app.controller('content',function ($scope,$http,$location) {
				
				var leave_id = $location.search().id;
				// 测试下 #后面的变量
				//alert(leave_id);
				// 设置body里面的变量
				$scope.show_order=['name','category','start_time','end_time','reason','create_time','status']
				$scope.name_map=name_map
				
				if(is_local){
					$scope.leave=fake_leave_application;
					$scope.current_user={cn_name:'何宇林'}
				}else{
					// 从服务器初始化
					var post_url='/attendance/ajax/';
					function init_from_server() {
							var post_data = {
									leave_detail:{leave_id:leave_id},
									current_user:{}
								};  
							$http.post(post_url,post_data)
							.success(function(data, status, headers, config) { 
								if (data.leave_detail.status=='success'){
									$scope.leave=data.leave_detail.leave
									$scope.current_user=data.current_user
								}else{
									info(data.leave_detail.msg,function () {
										location='leave_info'
									})
								}
								
							}).error(function(data, status, headers, config) {  
							    //处理错误 
							    $scope.std='有错误,返回码为:'+status;
							});
					}
					init_from_server();
					//--------------------------------------
				}
			$scope.map_dp_type=function (type,value) {
				if(type=='category'){
					return $scope.name_map[value]
				}else{
					return value
				}
			}
			$scope.cannel_leave=function () {
				assure("when revoke leave,you can't Resume it again",function (b) {
				if(b){
					var postData = {
					revoke_leave:{leaveid:leave_id},
						};  
					$http.post(post_url,postData)
					.success(function(data, status, headers, config) {  
						if(data.revoke_leave.status=='success'){
							info('successful submit',function () {
								location="leave_info";
							});
						}else{
							info(data.revoke_leave.msg);
						}
					}).error(function(data, status, headers, config) {  
					    //处理错误 
					    info('有错误,返回码为:'+status)
					});
				}
				
			})
		};
				
			})
		</script>

<style>
		body{
			text-transform: capitalize;
		}
		.topDiv{
			padding: 1.5em 0;
			font-size: 1.5em;
			font-weight: 600;
			text-align: center;
			color: #ffffff;
			background: url("[[static]]/img/192396266.jpg") no-repeat center;
		}
		.timePut{
			height: 3em;
			line-height: 3em;
			border: 1px solid #1686E2;
			border-radius: 4px;
			vertical-align: middle;
			margin: 0.8em auto 0.8em 1.5em;
		}
		.invalid{
			border-color:#ff6014;
		}
		.valid{
			border-color:#1686E2;
		}
</style>
</head>
<body ng-controller='content'>
		<!-----------------弹出框------------------------>
	<div ng-include src='"info_panel.html"'></div>
		<!-----------------在这里填写内容------------------------>

	<div class="container">
		<div class="row">
			<div class="page-header">
			  	<h1>申请详情
			  		<small>
					  	<span ng-bind='current_user.cn_name'></span>
					 </small>
				</h1>
			</div>
			
			<p class="remaining">申请内容</p>

			<table class="table">
				<tr ng-repeat='name in show_order'>
					<td ng-bind='name_map[name]'></td>
					<td ng-bind='map_dp_type(name,leave[name])'></td>
				</tr>
			</table>
			<p class="remaining">审批情况</p>
			<div ng-repeat='leader in leave.check_record' style="padding: 20px;border-bottom: 1px solid #999;">
				<div style='margin-bottom:10px;'><b ng-bind='leader.name'></b>
					<span ng-bind='leader.status' style='margin-left:20px;'></span>
				</div>
				<div><b>留言:</b><span ng-bind='leader.note'></span></div>
			</div>

			<div class="btncenter"  id='menu'>

			<button type="button" class="btn btn-warning" ng-click='cannel_leave()' ng-hide='leave.status!="pending"'>撤销</button>
			</div>
		</div>
	</div>

		
	</body>
</html>